<?php

namespace App\Http\Controllers;

use App\Models\Category;
use Illuminate\Http\Request;

class CategoryController extends Controller
{
    //
    public function index()
    {
        $category = Category::orderBy('is_use','DESC')->orderBy('cate_sort','DESC')->get();
        return view('category.index',compact('category'));
    }

    public function isuse(Request $request)
    {
        $result = Category::where('cate_id',$request->get('id'))->update(['is_use' => $request->get('use')]);
        return $result;
    }

    public function updateSort(Request $request)
    {
        $result = Category::where('cate_id',$request->get('id'))->update(['cate_sort' => $request->get('val')]);
        return $result;
    }
}
